package com.rocching.easychat.service;

import com.rocching.easychat.core.IApiCallback;
import com.rocching.easychat.core.UserIdentityContext;
import com.rocching.easychat.model.AgreeUserListModel;
import com.rocching.easychat.model.FriendListModel;
import com.rocching.easychat.model.FriendModel;
import com.rocching.easychat.model.MyFriendListModel;
import com.rocching.easychat.model.ResponseModel;
import com.rocching.easychat.model.SearchUserModel;
import com.rocching.easychat.service.dto.AddFriendInput;
import com.rocching.easychat.service.dto.BeFriendInput;
import com.rocching.easychat.util.HttpUtil;

import java.util.List;

public class FriendService {
    private static FriendService instance;

    public static FriendService getInstance() {
        if (instance == null) {
            instance = new FriendService();
        }
        return instance;
    }

    public void getFriendList(IApiCallback<FriendListModel> callback) {
        HttpUtil.get(String.format("/api/RCFriend/GetFriendList/%s", UserIdentityContext.getUserId()), callback, FriendListModel.class);
    }

    public void getFriendListByUserId(IApiCallback<MyFriendListModel> callback) {
        HttpUtil.get(String.format("/api/RCFriend/GetFriendListByUserId/%s", UserIdentityContext.getUserId()), callback, MyFriendListModel.class);
    }

    public void getFriend(String userId, IApiCallback<FriendModel> callback) {
        HttpUtil.get(String.format("/api/RCFriend/GetFriend/%s", userId), callback, FriendModel.class);
    }

    public void getAgreeFriendList(IApiCallback<AgreeUserListModel> callback) {
        HttpUtil.get("/api/RCFriend/GetAgreeUserList", callback, AgreeUserListModel.class);
    }

    public void searchFriend(String keyword, IApiCallback<Object> callback) {
        HttpUtil.post(String.format("/api/RCFriend/Search/%s", keyword), null, callback, Object.class);
    }

    public void addFriend(AddFriendInput input, IApiCallback<ResponseModel> callback) {
        HttpUtil.post("/api/RCFriend/AddFriend", input, callback, ResponseModel.class);
    }

    public void beFriend(BeFriendInput input, IApiCallback<ResponseModel> callback) {
        HttpUtil.post("/api/RCFriend/BeFriend", input, callback, ResponseModel.class);
    }
}
